[id].vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 页面导航 -->
  5. <HomePageNavigation></HomePageNavigation>
  6. <!-- 广告1 -->
  7. <HomeAdvertising :imgurl="adImg1"></HomeAdvertising>
  8. <!-- 面包屑导航 -->
  9. <div class="breadcrumb breadcrumb_phone_none">
  10. <div class="inner">
  11. <span class="location">当前位置:</span>
  12. <el-breadcrumb :separator-icon="ArrowRight">
  13. <el-breadcrumb-item>
  14. <NuxtLink to="/">首页</NuxtLink>
  15. </el-breadcrumb-item>
  16. <el-breadcrumb-item>
  17. <NuxtLink :to="`/${targetSegment}/index.html`">
  18. {{ routLevelTitle }}
  19. </NuxtLink>
  20. </el-breadcrumb-item>
  21. <el-breadcrumb-item>{{ routeNewsTtitle }}</el-breadcrumb-item>
  22. </el-breadcrumb>
  23. </div>
  24. </div>
  25. <div class="breadcrumb_box breadcrumb_pc_none">
  26. <span class=" ">当前位置:</span>
  27. <NuxtLink to="/">首页</NuxtLink>
  28. <span class=" ">&gt;</span>
  29. <NuxtLink :to="`/${targetSegment}/index.html`"> {{ routLevelTitle }}</NuxtLink>
  30. <span class=" ">&gt;</span>
  31. <span class=" ">
  32. {{ routeNewsTtitle }}
  33. </span>
  34. </div>
  35. <!-- 资讯列表 -->
  36. <div class="newsDetail">
  37. <div class="inner">
  38. <div class="innerLeft">
  39. <div class="LeftTop">
  40. <h1>{{ newsDetail.title }}</h1>
  41. <p class="phone_none">
  42. 来源: <span>{{ newsDetail.copyfrom }}</span>
  43. 作者: <span>{{ newsDetail.author }}</span>
  44. 发布时间: <span>{{ time }}</span>
  45. </p>
  46. <p class="pc_none">
  47. <span>{{ newsDetail.copyfrom }}</span>
  48. <span>{{ newsDetail.author }}</span>
  49. <span>{{ time }}</span>
  50. </p>
  51. </div>
  52. <div class="leftBottom" v-html="newsDetail.content" v-if="newsDetail.content" @click="openPreview">
  53. </div>
  54. <div v-if="previewVisible" class="preview-modal" @click="closePreview">
  55. <img :src="selectedImage" alt="Preview">
  56. </div>
  57. <!-- 免责声明: -->
  58. <div class="disclaimer" v-if="newsDetail.fromurl">
  59. <p>原文链接:{{ newsDetail.fromurl }}</p>
  60. <p>[免责声明]本文来源于网络转载,仅供学习交流使用,不构成商业目的。 版权归原作者所有,如涉及作品内容,版权和其他问题,请在30日与本网联系,我们将第一时间处理。</p>
  61. </div>
  62. <div v-if="articleChoice">
  63. <!-- 投票 start ---------------------------------------->
  64. <div class="index_3_box_vote" v-if="articleChoice">
  65. <div class="voteTitle">投票区</div>
  66. <div class="inquire">
  67. <p v-if="voteList.length > 0">{{ voteList[0].survey_name }}</p>
  68. <div class="radioBox">
  69. <!--投票选项-->
  70. <div v-if="!isDisabled">
  71. <div class="radio" v-if="isRadio">
  72. <el-radio-group v-model="radio1" @change="handleRadioChange">
  73. <el-radio v-for="item in voteList" :key="item.id" :value="item.id"
  74. size="large">
  75. <span v-if="item.is_other == 0">{{ item.choice_name }}</span>
  76. <span v-else>其他</span>
  77. </el-radio>
  78. </el-radio-group>
  79. <el-input v-if="showUserChoice" v-model="userChoice" :rows="2" type="textarea"
  80. resize="none" placeholder="请输入.." />
  81. </div>
  82. <div class="checkInputBox" v-else>
  83. <el-checkbox-group v-model="check1" @change="handleCheckboxChange">
  84. <span v-for="item in voteList" :key="item.id">
  85. <span v-if="item.is_other == 0">
  86. <el-checkbox size="large" :label="item.choice_name"
  87. :value="item.id" />
  88. </span>
  89. <span v-else>
  90. <el-checkbox size="large" label="其他" :value="item.id" />
  91. </span>
  92. </span>
  93. </el-checkbox-group>
  94. <el-input v-if="showUserChoice" v-model="userChoice" :rows="2" type="textarea"
  95. resize="none" placeholder="请输入.." />
  96. </div>
  97. </div>
  98. <!--投票结果-->
  99. <div class="inquireData" v-else>
  100. <div v-for="item in websiteSurveyData.data" :key="item.id">
  101. <div class="inquireDataItem active" v-if="item.status == 1">
  102. <div class="inquireDataItemTitle">
  103. <span v-if="item.choice_name == ''">其他</span>
  104. <span v-else>{{ item.choice_name }}</span>
  105. </div>
  106. <div class="inquireDataItemNum">{{ item.results }}票</div>
  107. </div>
  108. <div class="inquireDataItem" v-else>
  109. <div class="inquireDataItemTitle">
  110. <span v-if="item.choice_name == ''">其他</span>
  111. <span v-else>{{ item.choice_name }}</span>
  112. </div>
  113. <div class="inquireDataItemNum">{{ item.results }}票</div>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. <div class="btn">
  119. <button class="voting" @click="addWebsiteSurvey" :disabled="isDisabled"
  120. v-if="!isDisabled">投票</button>
  121. </div>
  122. </div>
  123. </div>
  124. <!-- 投票 end ---------------------------------------->
  125. </div>
  126. <!-- 推荐阅读 -->
  127. <div class="recommendRead" v-if="newsDetail.commendArticle != false">
  128. <div class="recommendReadTitle phone_none">
  129. 推荐阅读
  130. <em></em>
  131. </div>
  132. <div class="recommend_read_head_box pc_none">
  133. <span class="recommend_read_head">
  134. 推荐阅读
  135. </span>
  136. </div>
  137. <div class="recommendReadList">
  138. <div class="recommendReadListTitle" v-for="(item, index) in newsDetail.commendArticle"
  139. :key="item.id">
  140. <a :href="`/${item.alias_pinyin}/${item.id}.html`" v-if="index < 3">
  141. {{ item.title }}
  142. </a>
  143. <span v-if="index < 3">{{ getTime(item.created_at,"month",1) }}</span>
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. <div class="innerRight">
  149. <!-- 热点资讯1 -->
  150. <div class="hotList1">
  151. <DetailHotNews></DetailHotNews>
  152. </div>
  153. <!-- 热点资讯2 -->
  154. <div class="hotList2">
  155. <DetailHotNews2></DetailHotNews2>
  156. </div>
  157. </div>
  158. </div>
  159. </div>
  160. <!-- 广告2 -->
  161. <HomeAdvertising :imgurl="adImg2"></HomeAdvertising>
  162. <!-- 页面底部 -->
  163. <HomeFoot1></HomeFoot1>
  164. </template>
  165. <script setup>
  166. //1.页面依赖 start ---------------------------------------->
  167. import { onMounted } from 'vue'
  168. import { ElBreadcrumb, ElBreadcrumbItem, ElRadio, ElRadioGroup, ElMessage, ElCheckboxGroup, ElCheckbox, ElInput } from 'element-plus'
  169. import { ArrowRight } from '@element-plus/icons-vue'
  170. //1.1 获得跳转过来的id
  171. const route = useRoute();
  172. //获得详情id
  173. const articleId = parseInt(route.params.id); //获得该页面的id
  174. //获得当前的完整路径
  175. const fullPath = route.path;
  176. //拆分,取出来中间这一段,然后提取数字部分
  177. const segments = fullPath.split('/');
  178. const targetSegment = segments[1];
  179. // const numberPart = targetSegment.match(/\d+$/)?.[0];
  180. // let routeId = 20 //排除路径错误可以打开这个
  181. // const routeId = numberPart;
  182. let routeId;
  183. //通过导航路径反向查询导航id
  184. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  185. method: 'GET',
  186. query: {
  187. 'pinyin': targetSegment,
  188. },
  189. });
  190. if (getRouteId.code == 200) {
  191. routeId = getRouteId.data.category_id
  192. } else {
  193. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  194. console.log("错误位置:通过url路径查询导航池id")
  195. console.log("后端错误反馈:", getRouteId.message)
  196. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  197. }
  198. //1.2 获得父级栏目的名称、id
  199. const parent_name = ref([]);
  200. const parent_id = ref([]);
  201. const parent_pinyin = ref("");
  202. const parent_children_count = ref(0)
  203. let getParentNav = async () => {
  204. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  205. method: 'GET',
  206. query: {
  207. 'catid': routeId
  208. },
  209. });
  210. console.log("获取父级栏目数据")
  211. console.log(listData)
  212. if (listData.code == 200) {
  213. console.log(listData.data);
  214. parent_name.value = listData.data.alias;
  215. parent_id.value = listData.data.parent_id;
  216. parent_pinyin.value = listData.data.aLIas_pinyin;
  217. parent_children_count = listData.data.children_coun;
  218. } else {
  219. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  220. console.log("错误位置:获取面包屑导航")
  221. console.log("后端错误反馈:", listData.message)
  222. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  223. }
  224. }
  225. //获得父级栏目详情
  226. // getParentNav();
  227. //1.页面依赖 end ---------------------------------------->
  228. //2.页面数据 start ---------------------------------------->
  229. //2.1 资讯详情
  230. const newsDetail = ref({})
  231. const routeNewsTtitle = ref("");
  232. //2.2 发布日期
  233. const time = ref("");
  234. //2.3 路径
  235. const routLevelTitle = ref("");
  236. const routLevelId = ref("");
  237. //是否展示投票
  238. const articleChoice = ref(false);
  239. //2.4获取详情
  240. async function getPageData() {
  241. const mkdata = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  242. method: 'GET',
  243. query: {
  244. 'articleid': articleId
  245. },
  246. });
  247. console.log("资讯详情", mkdata)
  248. if (mkdata.code == 200) {
  249. //判断是否显示投票
  250. if (mkdata.data.is_survey == 1) {
  251. console.log("本篇文章含有投票!")
  252. articleChoice.value = true;
  253. getVoteList();
  254. }
  255. //获取内容
  256. newsDetail.value = mkdata.data;
  257. //获取路径
  258. routLevelTitle.value = newsDetail.value.cat_name;
  259. routLevelId.value = newsDetail.value.category_id;
  260. //获取发布时间
  261. time.value = newsDetail.value.updated_at.split(' ')[0];
  262. //修正标题长度
  263. if (newsDetail.value.title.length >= 20) {
  264. routeNewsTtitle.value = newsDetail.value.title.substr(0, 20) + "...";
  265. } else {
  266. routeNewsTtitle.value = newsDetail.value.title
  267. }
  268. } else {
  269. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  270. console.log("错误位置:获取详情内容")
  271. console.log("后端错误反馈:", mkdata.message)
  272. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  273. }
  274. }
  275. getPageData();
  276. //2.5 获得广告
  277. //广告列表
  278. let adImg1 = ref([]);
  279. let adImg2 = ref([]);
  280. onMounted(async () => {
  281. const { $webUrl, $CwebUrl } = useNuxtApp();
  282. //广告1
  283. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=xcw_detail_0001`
  284. const responseAd1 = await fetch(url, {
  285. headers: {
  286. 'Content-Type': 'application/json',
  287. 'Userurl': $CwebUrl,
  288. 'Origin': $CwebUrl
  289. }
  290. });
  291. const resultAd1 = await responseAd1.json();
  292. adImg1.value = resultAd1.data[0];
  293. //广告2
  294. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=xcw_detail_0002`
  295. const responseAd2 = await fetch(url2, {
  296. headers: {
  297. 'Content-Type': 'application/json',
  298. 'Userurl': $CwebUrl,
  299. 'Origin': $CwebUrl
  300. }
  301. });
  302. const resultAd2 = await responseAd2.json();
  303. adImg2.value = resultAd2.data[0];
  304. })
  305. //2.页面数据 end ---------------------------------------->
  306. //3.设置seo信息 start---------------------------------------->
  307. //3.1 设置seo信息
  308. const setData = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  309. method: 'GET',
  310. query: {
  311. 'articleid': articleId
  312. },
  313. });
  314. if (setData.code == 200) {
  315. let seoTitle = setData.data.title;
  316. let seoDescription = setData.data.introduce;
  317. let seoKeywords = setData.data.keyword;
  318. let seoSuffix = setData.data.suffix;
  319. let seoName = setData.data.website_name;
  320. useSeoMeta({
  321. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  322. meta: [
  323. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  324. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  325. { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no' }
  326. ]
  327. });
  328. } else {
  329. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  330. // console.log("错误位置:设置详情页面SEO数据")
  331. // console.log("后端错误反馈:", setData.message)
  332. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  333. }
  334. //3.设置seo信息 end---------------------------------------->
  335. //4.投票 start---------------------------------------->
  336. const radio1 = ref(''); //单选
  337. const check1 = ref([]); //多选
  338. const isDisabled = ref(false);//是否禁用提交按钮
  339. const isRadio = ref(true);//是否渲染单选
  340. const userSurId = ref('');//投票属于哪一篇文章
  341. const userChoice = ref('');//用于判断用户选择了其他选项以后,输入的值
  342. const userIsChoice = ref('');//用于判断其他选项目前是什么值
  343. const showUserChoice = ref(false);//是否显示其他输入框
  344. const websiteSurveyData = ref([]);//投票结果
  345. //3.2获得投票列表
  346. let voteList = ref([]);
  347. async function getVoteList() {
  348. const voteData = await requestHome('/web/getWebsiteSurvey', { method: 'GET', query: { 'art_id': articleId } });
  349. console.log(778899)
  350. console.log('778899', voteData)
  351. if (voteData.code == 200) {
  352. voteList.value = voteData.data;
  353. console.log(voteList.value)
  354. //判断显示单选还是多选
  355. //survey_type 0是单选 1是多选
  356. if (voteData.data[0].survey_type == 0) {
  357. isRadio.value = true;
  358. console.log("1111")
  359. } else {
  360. isRadio.value = false;
  361. }
  362. //把最后一个的值拿出来 用于判断用户是否选择了其他
  363. for (let item of voteData.data) {
  364. //如果含有其他
  365. if (item.is_other == 1) {
  366. userIsChoice.value = item.id;
  367. }
  368. }
  369. //用户投票属于哪一篇文章
  370. userSurId.value = voteData.data[0].sur_id;
  371. } else {
  372. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  373. console.log("错误位置:首页投票")
  374. console.log("后端错误反馈:", voteData.message)
  375. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  376. }
  377. }
  378. //3.2当用户选择了选项,判断是否展示其他输入框
  379. const handleRadioChange = (value) => {
  380. console.log('11111', value, userIsChoice.value);
  381. if (value == userIsChoice.value) {
  382. showUserChoice.value = true;
  383. } else {
  384. showUserChoice.value = false;
  385. }
  386. }
  387. const handleCheckboxChange = (value) => {
  388. if (value.includes(userIsChoice.value)) {
  389. showUserChoice.value = true;
  390. } else {
  391. showUserChoice.value = false;
  392. }
  393. }
  394. //3.2发起投票
  395. async function addWebsiteSurvey() {
  396. //判断当前是单选还是多选
  397. console.log(isRadio.value)
  398. if (isRadio.value) {
  399. console.log("用户单选!")
  400. if (radio1.value != '') {
  401. //先判断一下是否使用了其他选项
  402. if (showUserChoice.value) {
  403. if (userChoice.value != '') {
  404. //文章id
  405. // console.log(userSurId.value)
  406. // 用户输入的值
  407. // console.log(userChoice.value)
  408. //如果使用了其他,其他的选项需要增加进去
  409. const ChoiceData = await requestHome('/web/addWebsiteSurveyOption', {
  410. method: 'GET',
  411. query: {
  412. 'sur_id': userSurId.value,//投票的新闻id
  413. 'choice_name': userChoice.value,//投票的选项id
  414. }
  415. });
  416. if (ChoiceData.code == 200) {
  417. //提交完其他选项以后,再正式发起投票
  418. const mkData = await requestHome('/web/addWebsiteSurveyVote', {
  419. method: 'GET',
  420. query: {
  421. 'sur_id': userSurId.value,
  422. 'choice_id': ChoiceData.data
  423. }
  424. });
  425. if (mkData.code == 200) {
  426. ElMessage.success('投票成功!')
  427. //把投票结果显示到页面上 禁用投票按钮
  428. isDisabled.value = true;
  429. websiteSurveyData.value = mkData.data;
  430. //遍历一下,把用户选中的那个设置status为1
  431. let data = mkData.data;
  432. //遍历一下,把用户选中的那个设置status为1
  433. for (let item of data.data) {
  434. for (let i of data.choice) {
  435. if (item.id == i) {
  436. console.log(item.id)
  437. item.status = 1;
  438. }
  439. }
  440. }
  441. websiteSurveyData.value = data;
  442. } else {
  443. ElMessage.error(mkData.message)
  444. }
  445. } else {
  446. ElMessage.error('其他投票失败!')
  447. }
  448. } else {
  449. ElMessage.error('请输入选项内容!')
  450. }
  451. } else {
  452. console.log('111', userSurId.value);
  453. console.log('222', radio1.value);
  454. //如果没选择其他,直接提交选择的内容
  455. const mkData = await requestHome('/web/addWebsiteSurveyVote', {
  456. method: 'GET',
  457. query: {
  458. 'sur_id': userSurId.value,
  459. 'choice_id': radio1.value
  460. }
  461. });
  462. if (mkData.code == 200) {
  463. ElMessage.success('投票成功!')
  464. //把投票结果显示到页面上 禁用投票按钮
  465. isDisabled.value = true;
  466. let data = mkData.data;
  467. //遍历一下,把用户选中的那个设置status为1
  468. for (let item of data.data) {
  469. for (let i of data.choice) {
  470. if (item.id == i) {
  471. item.status = 1;
  472. }
  473. }
  474. }
  475. websiteSurveyData.value = data;
  476. } else {
  477. ElMessage.error('投票失败!')
  478. }
  479. }
  480. } else {
  481. ElMessage.error('请选择一个选项')
  482. }
  483. } else {
  484. console.log("多选!")
  485. //多选
  486. if (check1.value != []) {
  487. //先判断一下是否使用了其他选项
  488. if (showUserChoice.value) {
  489. if (userChoice.value != '') {
  490. //判断用户是否只选择了一个其他
  491. if (check1.value.length == 1) {
  492. const ChoiceData = await requestDataPromise('/web/addWebsiteSurveyOption', {
  493. method: 'GET',
  494. query: {
  495. 'sur_id': userSurId.value,//投票的新闻id
  496. 'choice_name': userChoice.value,//用户输入的其他选项文字
  497. }
  498. });
  499. if (ChoiceData.code == 200) {
  500. //提交完其他选项以后,再正式发起投票
  501. const mkData = await requestDataPromise('/web/addWebsiteSurveyVote', {
  502. method: 'GET',
  503. query: {
  504. 'sur_id': userSurId.value,
  505. 'choice_id': ChoiceData.data
  506. }
  507. });
  508. if (mkData.code == 200) {
  509. ElMessage.success('投票成功!')
  510. //把投票结果显示到页面上 禁用投票按钮
  511. isDisabled.value = true;
  512. websiteSurveyData.value = mkData.data;
  513. //遍历一下,把用户选中的那个设置status为1
  514. let data = mkData.data;
  515. //遍历一下,把用户选中的那个设置status为1
  516. for (let item of data.data) {
  517. for (let i of data.choice) {
  518. if (item.id == i) {
  519. console.log(item.id)
  520. item.status = 1;
  521. }
  522. }
  523. }
  524. websiteSurveyData.value = data;
  525. } else {
  526. ElMessage.error(mkData.message)
  527. }
  528. } else {
  529. ElMessage.error('其他投票失败!')
  530. }
  531. } else {
  532. //用户选择了除了其他以外,还包括别的选项
  533. const ChoiceData = await requestDataPromise('/web/addWebsiteSurveyOption', {
  534. method: 'GET',
  535. query: {
  536. 'sur_id': userSurId.value,//投票的新闻id
  537. 'choice_name': userChoice.value,//用户输入的其他选项文字
  538. }
  539. });
  540. if (ChoiceData.code == 200) {
  541. let data = check1.value;
  542. //找到多选的数组,把其他默认值给替换掉
  543. for (let i = 0; i < data.length; i++) {
  544. if (data[i] == userIsChoice.value) {
  545. data[i] = ChoiceData.data;
  546. }
  547. }
  548. let jsonArray = JSON.stringify(data);
  549. //提交完其他选项以后,再正式发起投票
  550. const mkData = await requestDataPromise('/web/addWebsiteSurveyVote', {
  551. method: 'GET',
  552. query: {
  553. 'sur_id': userSurId.value,
  554. 'choice_id': jsonArray
  555. }
  556. });
  557. if (mkData.code == 200) {
  558. ElMessage.success('投票成功!')
  559. //把投票结果显示到页面上 禁用投票按钮
  560. isDisabled.value = true;
  561. websiteSurveyData.value = mkData.data;
  562. //遍历一下,把用户选中的那个设置status为1
  563. let data = mkData.data;
  564. //遍历一下,把用户选中的那个设置status为1
  565. for (let item of data.data) {
  566. for (let i of data.choice) {
  567. if (item.id == i) {
  568. //console.log(item.id)
  569. item.status = 1;
  570. }
  571. }
  572. }
  573. websiteSurveyData.value = data;
  574. } else {
  575. ElMessage.error(mkData.message)
  576. }
  577. } else {
  578. ElMessage.error('其他投票失败!')
  579. }
  580. }
  581. } else {
  582. ElMessage.error('请输入选项内容!')
  583. }
  584. } else {
  585. let jsonArray = JSON.stringify(check1.value);
  586. //如果没选择其他,直接提交选择的内容
  587. const mkData = await requestDataPromise('/web/addWebsiteSurveyVote', {
  588. method: 'GET',
  589. query: {
  590. 'sur_id': userSurId.value,
  591. 'choice_id': jsonArray
  592. }
  593. });
  594. if (mkData.code == 200) {
  595. ElMessage.success('投票成功!')
  596. //把投票结果显示到页面上 禁用投票按钮
  597. isDisabled.value = true;
  598. websiteSurveyData.value = mkData.data;
  599. //遍历一下,把用户选中的那个设置status为1
  600. let data = mkData.data;
  601. //遍历一下,把用户选中的那个设置status为1
  602. for (let item of data.data) {
  603. for (let i of data.choice) {
  604. if (item.id == i) {
  605. console.log(item.id)
  606. item.status = 1;
  607. }
  608. }
  609. }
  610. websiteSurveyData.value = data;
  611. } else {
  612. ElMessage.error('投票失败!')
  613. }
  614. }
  615. } else {
  616. ElMessage.error('请选择一个选项')
  617. }
  618. }
  619. }
  620. //4.投票 end---------------------------------------->
  621. //5.页面图片放大 start---------------------------------------->
  622. const previewVisible = ref(false)
  623. const selectedImage = ref(' ')
  624. const openPreview = (event) => {
  625. if (event.target.tagName === 'IMG') {
  626. selectedImage.value = event.target.src;
  627. previewVisible.value = true;
  628. }
  629. }
  630. const closePreview = () => {
  631. previewVisible.value = false;
  632. }
  633. //5.页面图片放大 end---------------------------------------->
  634. </script>
  635. <style lang="less" scoped>
  636. @import url('@/assets/css/detail.less');
  637. </style>
  638. <style lang="less" scoped>
  639. @media screen and (min-width:801px){/*pc*/
  640. .breadcrumb_pc_none{display:none!important;}
  641. .pc_none{display:none;}
  642. }
  643. @media screen and (max-width:800px){/*ipad_phone*/
  644. .index_3_box_vote{overflow:hidden;margin-top:39px;}
  645. .index_3_box_vote .inquire{margin-top:15px;height:auto;}
  646. .index_3_box_vote .inquire p{height:auto;padding:0;font-size:14px;
  647. margin:0px 0px 5px 18px;}
  648. .index_3_box_vote .inquire .radio .el-radio.el-radio--large .el-radio__label span{font-size:14px;}
  649. .index_3_box_vote .voteTitle{font-size:14px;}
  650. .index_3_box_vote .inquire .btn{padding-left:22px;}
  651. .index_3_box_vote .inquire .radio .el-radio.el-radio--large{margin-bottom:3px;}
  652. .index_3_box_vote .inquire .radioBox{height:auto;
  653. padding:0px 0px 12px 18px;}
  654. .index_3_box_vote .inquire .radio .el-radio-group{width:100%;}
  655. .index_3_box_vote .inquire .btn button{width:auto;padding:0px 10px;line-height:33px;height:33px;font-size:14px;margin-bottom:14px;}
  656. .newsDetail .inner{width:92%;}
  657. .newsDetail .inner .innerLeft{width:100%;margin:0;float:none;border-top:solid 1px #A01C0E;}
  658. .newsDetail .inner .innerLeft .LeftTop{margin-top:15px;}
  659. .newsDetail .inner .innerLeft .LeftTop > h1{font-size:20px;line-height:28px;margin:15px auto 15px;}
  660. .newsDetail .inner .innerLeft .leftBottom{width:100%;margin-top:15px;}
  661. .newsDetail .inner .innerLeft .leftBottom /deep/img{max-width:100%;height:auto; }
  662. .breadcrumb_box{
  663. height:22px;width:100%;margin:16px auto 9px;
  664. word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  665. width:92%;
  666. font-size:14px;
  667. color:#666;
  668. *{
  669. font-size:14px;
  670. display:inline ;
  671. color:#666;
  672. line-height:22px;height:22px;
  673. margin-right:5px;
  674. }
  675. }
  676. // 推荐阅读
  677. .newsDetail .inner .innerLeft .recommendRead{width:100%; margin:25px auto 32px;}
  678. .newsDetail .inner .innerLeft .recommendRead .recommendReadTitle{width:100%;margin:22px 0px;}
  679. .recommend_read_head_box{overflow:hidden;border-bottom:1px solid #D9D9D9;}
  680. .recommend_read_head{
  681. width:auto;font-size:14px;box-sizing:border-box;height:33px;line-height:33px;
  682. color: #A01C0E;
  683. border-bottom:1px solid #A01C0E;float:left;
  684. }
  685. .newsDetail .inner .innerLeft .recommendRead .recommendReadList{
  686. height:auto;margin-top:11px; min-height:auto;padding-bottom:8px;
  687. }
  688. .newsDetail .inner .innerLeft .recommendRead .recommendReadList .recommendReadListTitle{
  689. margin-top:0px;overflow:hidden;width:100%;
  690. }
  691. .newsDetail .inner .innerLeft .recommendRead .recommendReadList .recommendReadListTitle a{
  692. line-height:33px;height:33px;font-size:14px;float:left;max-width:90%;
  693. word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  694. }
  695. .newsDetail .inner .innerLeft .LeftTop > p span:nth-last-of-type(1){margin-right:0px;}
  696. .newsDetail .inner .innerLeft .LeftTop > p{height:auto;}
  697. .newsDetail .inner .innerLeft .recommendRead .recommendReadList .recommendReadListTitle span{display:none;}
  698. .newsDetail .inner .innerRight{display:none;}
  699. .breadcrumb_phone_none{display:none!important;}
  700. .phone_none{display:none;}
  701. }
  702. </style>